﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace peonwar
{
   public  class Achievert
    {

        public float speeed; // Augmenteur de Position
        float y ;
        string Top;
        string Bot;
        public Sprite Square = new Sprite(1110, 805, GameTexture.Achievement);
        public Sprite Half = new Sprite(1110, 750, GameTexture.Achievement_half);
        Achievements related;



       public Achievert(Achievements a)
       {
           this.Bot = a.desc;
           this.Top = a.name;
           this.related = a;
           this.speeed = -1.8F;
           this.y = 820;
       }

       public void Update()
       {           
           y += speeed;
           if (y < 620 && speeed < 0)
               speeed = 0.01f;
           if (y > 620.50 && speeed == 0.01f)
               speeed = 1.8F;
          
          
           if (speeed != 0.01f)
           {
               Square.Position = new Vector2(Square.Position.X, y);
               Half.Position = new Vector2(Half.Position.X, y + 60);
           }
           else
           {
               Square.Position = new Vector2(Square.Position.X, 620);
               Half.Position = new Vector2(Half.Position.X, 680);
           }
       }

       public void Draw(SpriteBatch spriteBatch)
       {
           Square.Draw(spriteBatch, null);
          
           spriteBatch.DrawString(GameData.Font_Achiev2, Top, new Vector2(Square.Position.X - Square.Texture.Width / 2 + 35, Square.Position.Y - 40), Color.Gray);        
           spriteBatch.DrawString(GameData.Font_Achiev2, Bot, new Vector2(Square.Position.X - Square.Texture.Width / 2 + 35, Square.Position.Y - 10), Color.DarkOrange);
           if (related.limit > 1 && related.locked)
           {
               Half.Draw(spriteBatch, null);
               spriteBatch.DrawString(GameData.Font_Achiev2, (int)(related.limit /2) + " / " + related.limit, new Vector2(Half.Position.X - Half.Texture.Width / 2 + 150, Half.Position.Y - 32), Color.WhiteSmoke);
            
           }
           else spriteBatch.DrawString(GameData.Font_Achiev, GameData.GameString[219], new Vector2(Square.Position.X - Square.Texture.Width / 2 + 50, Square.Position.Y - 70), Color.Black);

       }
    }
}
